﻿
@{
    ViewData["Title"] = "ProjectEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<div id="divForm" style="margin:2px;padding:2px;">
    <el-card>
        <el-form ref="form" :model="form" label-width="80px">
            <el-row :gutter="24">
                <el-col :span="6">
                    <el-form-item label="项目名称" required>
                        <el-input v-model="form.projectName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="6">
                    <el-form-item label="状态">
                        <el-radio-group v-model="form.enabled">
                            <el-radio :label='true'>启用</el-radio>
                            <el-radio :label='false'>禁用</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="6">
                    <el-form-item label="项目排序">
                        <el-input v-model="form.orderIndex" type="number"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item>
                <el-button type="primary" @@click="SaveProject()" size="mini">保存</el-button>
                <el-button @@click="Back()" size="mini">返回</el-button>
            </el-form-item>
        </el-form>
    </el-card>

</div>
<script>

    var vueProject = new Vue({
        el: '#divForm',
        data() {
            return {
                pageButtons: [],
                form: {
                    id: parseInt( getQueryString("id") || 0),
                    ProjectName: "", 
                    enabled: true,
                    orderIndex: 0 
                }
            }
        },
        created() {
            var _this = this;
            _this.GetProject(); 
        },
        methods: {
            GetProject() {
                var _this = this;
                _this.$get("@Url.Action("GetProject", "Routes")?Id=" + _this.form.id).then((res) => {
                    _this.form = res;
                });
            },
            SaveProject() {
                var _this = this;
                _this.form.orderIndex = parseInt(_this.form.orderIndex);
                _this.$post("@Url.Action("SaveProject", "Routes")", _this.form).then((res) => {
                    _this.$success(res.message, function () {
                        _this.$back(true);
                    });
                });
            },
            Back() {
                this.$back();
            }
        }
    });
</script>